package service.Imp;

import Dao.PersonalInfoDao;
import Dao.RoomMasterDao;
import Dao.UserApplicationDao;
import Dao.UserVideoDao;
import Request.LiveRequest;
import Request.VideoRequest;
import Response.Follow;
import modal.RoomMaster;
import modal.User;
import modal.UserApplication;

import modal.UserVideo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import service.PersonManageService;

import java.util.List;

/**
 * Created by Charlotte on 2017/8/23.
 */
@Service
public class PersonManageServiceImp implements PersonManageService{
    @Autowired
    PersonalInfoDao personalInfoDao;
    @Autowired
    UserApplicationDao userApplicationDao;
    @Autowired
    UserVideoDao userVideoDao;
    @Autowired
    RoomMasterDao roomMasterDao;
    public String updateInfo(User user) {
        return personalInfoDao.updateMyInfo(user);
    }

    public User getOneUser(String username) {
        return personalInfoDao.getOneUser(username);
    }

    public List<Follow> getfollows(String username) {
        return personalInfoDao.getMyFollow(username);
    }

    public String deletefollow(String username, String roomid) {
        return personalInfoDao.deleteMyFollow(username,roomid);
    }

    public String submitApplication(UserApplication application) {
        if (userApplicationDao.getOneApplication(application.getUsername())!=null)
        {
            return "repeat";
        }else
        {
            return personalInfoDao.submitApplication(application);
        }
    }



    public RoomMaster getMyRoom(String username) {
        return roomMasterDao.getRoomMasterByName(username);
    }

    public String updateRoomMaster(RoomMaster roomMaster) {
       return roomMasterDao.updateRoomMaster(roomMaster);
    }

    public String addVideo(VideoRequest videoRequest) {
        return  userVideoDao.addNewVideo(videoRequest);
    }

    public String openLive(LiveRequest id) {
        return roomMasterDao.openLive(id);
    }

    public RoomMaster getRoomInformationByRoomid(String Roomid) {
        return roomMasterDao.getRoomMasterByRoomid(Roomid);
    }
}
